/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import physics.Physics;

/**
 *
 * @author wida46061976
 */
public class Walls extends EntityObject {

    private int life = 3;
    private boolean rompible = false;

    public Walls() {
        setAnimation(new Animation());
        try {
            getAnimation().addFrame(new Image("resources/wall.png"), 1000);
            setPosX(940);
            setPosY(560);
            setPoly(getPosX() + 21, getPosX() + 42, getPosY(), getPosY() + 64);
            setActivated(false);
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public boolean isRompible() {
        return rompible;
    }

    public void setRompible(boolean rompible) {
        this.rompible = rompible;
    }

    public int getLife() {
        return life;
    }

    public void setLife(int life) {
        this.life = life;
    }

    public void Update(Physics phys, PlayableChar p) {
        if (!isActivated()) {
            try {
                if (phys.entityToEntityCollision(getPoly(), p.getPoly())) {
                    if (p.isLeft()) {
                        p.setPosX(getPosX() + 18.1f);
                    } else {
                        p.setPosX(getPosX() - 20.1f);
                    }
                }
            } catch (SlickException e) {
            }
        }
    }
}
